package com.changgou.goods.dao;

import com.changgou.goods.pojo.Spec;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SpecMapper extends Mapper<Spec> {

    /**
     * 根据分类名称查询规格-join
     * @param cate
     * @return
     */
    @Select("SELECT DISTINCT s.* FROM tb_spec as s \n" +
            "JOIN tb_category AS c on c.template_id = s.template_id\n" +
            "WHERE c.`name` = #{cate}")
    List<Spec> findByCate(String cate);

    /**
     * 根据分类名称查询规格-in
     * @param cate
     * @return
     */
    @Select("SELECT * FROM tb_spec WHERE template_id IN(\n" +
            "SELECT template_id FROM tb_category WHERE `name` = #{cate})")
    List<Spec> findByCate1(String cate);
}
